Skip to content

feat: generate TypedDict types for input-side models#738

Merged
vdusek merged 4 commits intomasterfrom
feat/generate-typeddicts-for-input-models
Apr 23, 2026
Merged

feat: generate TypedDict types for input-side models#738
vdusek merged 4 commits intomasterfrom
feat/generate-typeddicts-for-input-models

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 17, 2026

Summary

Adds TypedDict counterparts for input-side models so users passing plain dicts to resource-client methods get full type-checker support without importing Pydantic models.

  • Generate TypedDicts alongside Pydantic models via a second datamodel-code-generator pass (--output-model-type typing.TypedDict) in poe generate-models.
  • Split generated content into _models_generated.py / _typeddicts_generated.py. Hand-written _models.py / _typeddicts.py now only hold shapes not exposed by the OpenAPI spec (e.g. RequestInput, RequestInputDict).
  • Extend scripts/postprocess_generated_models.py to trim the TypedDict file to input-relevant classes (plus transitive deps), rename them with a Dict suffix, and add @docs_group('Typed dicts').
  • Widen resource-client input parameters (actor, task, task_collection, request_queue) to accept TypedDict | PydanticModel unions.
  • Update .rules.md and manual_regenerate_models.yaml to reflect the new layout.

Closes #666.

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Apr 17, 2026
@vdusek vdusek self-assigned this Apr 17, 2026
@github-actions github-actions Bot added this to the 138th sprint - Tooling team milestone Apr 17, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Apr 17, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.70%. Comparing base (fd0663e) to head (074ad0e).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #738      +/-   ##
==========================================
- Coverage   95.89%   95.70%   -0.19%     
==========================================
  Files          45       48       +3     
  Lines        5115     5218     +103     
==========================================
+ Hits         4905     4994      +89     
- Misses        210      224      +14     
Flag Coverage Δ
integration 95.70% <100.00%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek force-pushed the feat/generate-typeddicts-for-input-models branch 2 times, most recently from f63bb00 to 00f228a Compare April 20, 2026 12:58
@vdusek vdusek requested review from Pijukatel and janbuchar April 20, 2026 13:01
@vdusek
Copy link
Copy Markdown
Contributor Author

vdusek commented Apr 20, 2026

@Pijukatel @janbuchar Let me guys know what you think, this change also has some drawbacks:

  1. The postprocess script had to be extended significantly.
  2. Some models and TypedDicts still need to be maintained manually, so I split them into two modules (generated vs. hand-written). I am not sure about this structure.

@vdusek vdusek closed this Apr 20, 2026
@vdusek vdusek reopened this Apr 20, 2026
Comment thread tests/integration/test_request_queue.py Outdated
Comment thread docs/02_concepts/code/03_nested_sync.py
Comment thread src/apify_client/_typeddicts_generated.py
Comment thread src/apify_client/_types.py Outdated
Comment thread scripts/postprocess_generated_models.py Outdated
Comment thread scripts/postprocess_generated_models.py Outdated
Comment thread tests/unit/test_utils.py Outdated
vdusek and others added 4 commits April 23, 2026 13:17
Add TypedDict counterparts for generated Pydantic models so users passing
plain dicts to resource-client methods get full type-checker support without
importing Pydantic models. Closes #666.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vdusek vdusek force-pushed the feat/generate-typeddicts-for-input-models branch from 770be11 to 074ad0e Compare April 23, 2026 11:22
@vdusek vdusek merged commit 2fd66d0 into master Apr 23, 2026
48 of 49 checks passed
@vdusek vdusek deleted the feat/generate-typeddicts-for-input-models branch April 23, 2026 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate TypedDict types for input-side models

4 participants